package com.sunlee.admin.api.module.oss.cloud;

import io.github.artislong.core.StandardOssClient;
import io.github.artislong.model.OssInfo;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

/**
 * 云存储(支持七牛、阿里云、腾讯云)
 *
 * @author sunlee
 */
public abstract class AbstractCloudStorageService implements StandardOssClient {

    /**
     * 云存储配置信息
     */
    public CloudStorageConfig config;

    /**
     * OSS客户端操作
     */
    public StandardOssClient ossClient;

    public void init(StandardOssClient standardOssClient) {
        ossClient = standardOssClient;
    }

    /**
     * 对外暴露配置方法
     */
    public CloudStorageConfig getConfig() {
        return config;
    }

    public StandardOssClient getOssClient() {
        return ossClient;
    }

    @Override
    public OssInfo upLoad(InputStream is, String targetName, Boolean isOverride) {
        return ossClient.upLoad(is, targetName, isOverride);
    }

    @Override
    public OssInfo upLoadCheckPoint(File file, String targetName) {
        return ossClient.upLoadCheckPoint(file, targetName);
    }

    @Override
    public OssInfo getInfo(String targetName) {
        return ossClient.getInfo(targetName);
    }

    @Override
    public void downLoad(OutputStream os, String targetName) {
        ossClient.downLoad(os, targetName);
    }

    @Override
    public void downLoadCheckPoint(File localFile, String targetName) {
        ossClient.downLoadCheckPoint(localFile, targetName);
    }

    @Override
    public void delete(String targetName) {
        ossClient.delete(targetName);
    }

    @Override
    public void copy(String sourceName, String targetName, Boolean isOverride) {
        ossClient.copy(sourceName, targetName, isOverride);
    }

    @Override
    public OssInfo getInfo(String targetName, Boolean isRecursion) {
        return ossClient.getInfo(targetName, isRecursion);
    }

    @Override
    public Map<String, Object> getClientObject() {
        return ossClient.getClientObject();
    }

    @Override
    public String getBasePath() {
        return ossClient.getBasePath();
    }
}
